<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>质检合格未上架看板</title>
    <link rel="stylesheet" href="/3nod_web/layui/css/layui.css" media="all">
</head>
<body>
<div id="content">
    <h1>质检合格未上架看板</h1>


    <div class="layui-form-item" style="margin-top: 20px">
        <div class="layui-inline">
            <a href="/3nod_web/exportUnQualifiedQuality">
                <button class="layui-btn layui-btn layui-btn-sm">导出</button>
            </a>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">货主</label>
            <div class="layui-input-inline" style="width:168px;">
                <input type="text" name="storerkey" id="storerkey" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">物料编码</label>
            <div class="layui-input-inline" style="width:168px;">
                <input type="text" name="sku" id="sku" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">ASN/收货单</label>
            <div class="layui-input-inline" style="width:168px;">
                <input type="text" name="receiptkey" id="receiptkey" autocomplete="off" class="layui-input">
            </div>
        </div>
    </div>
    <table class="layui-hide" id="demo" lay-filter="demo"></table>
</div>


<script src="/3nod_web/layui/layui.js" charset="utf-8"></script>
<script src="/3nod_web/js/jquery-1.8.3.js" charset="utf-8"></script>
<script>

    var active;
    layui.use('table', function () {
        var table = layui.table;

        //方法级渲染
        table.render({
            elem: '#demo'
            , url: '/3nod_web/report/unQualifiedQualityList/'
            , cols: [
                [
                    {field: 'storerkey', title: '据点', sort: true, fixed: true, width: 80}
                    , {field: 'sku', title: '品号', sort: true, fixed: true, width: 100}
                    , {field: 'receiptKey', title: 'ASN/收货单', width: 150}
                    , {field: 'deliveryNumber', title: '送货单号', width: 150}
                    , {field: 'voucherType', title: '单据类型', width: 150}
                    , {field: 'receiveTime', title: '收货日期', width: 150}
                    , {field: 'receivingClerk', title: '收货员', width: 150}
                    // , {field: 'supplierCode', title: '供应商代码'}
                    , {field: 'supplierShort', title: '供应商简称', width: 150}
                    // , {field: 'purchaseOrder', title: '采购订单'}
                    // , {field: 'purchaseItems', title: '采购项次'}
                    , {field: 'descr', title: '品名', width: 150}
                    // , {field: 'specification', title: '规格'}
                    , {field: 'goodsQuantity', title: '计划收货数量', width: 150}
                    , {field: 'unit', title: '单位', width: 80}
                    // , {field: 'putawayQty', title: '已上架数量'}
                    , {field: 'unPutawayQty', title: '待上架数量', width: 150}
                    , {field: 'unPutawayTime', title: '未上架时间', width: 150}
                ]
            ]
            , id: 'testReload'
            , height: 'full-90'
            , page: true
            , limits: [20, 50, 100, 200, 500, 1000, 2000, 3000, 4000, 5000]
            , limit: 20
        });

        active = {
            reload: function () {
                var storerkey = $('#storerkey');
                var sku = $('#sku');
                var receiptkey = $('#receiptkey');
                var recodePage = parseInt($(".layui-laypage-skip .layui-input").val());
                var recodeLimit = $(".layui-laypage-limits").find("option:selected").val();
                if (recodePage > recodeLimit) {
                    recodePage = 0;
                }
                //执行重载
                table.reload('testReload', {
                    page: {
                        curr: recodePage + 1 //重新从第 1 页开始
                    }
                    , where: {
                        storerkey: storerkey.val(),
                        sku: sku.val(),
                        receiptkey: receiptkey.val(),
                    }
                }, 'data');
            }
        };
        //按回车提交
        $(".layui-input-inline").keydown(function (e) {//当按下按键时
            if (e.which == 13) {//.which属性判断按下的是哪个键，回车键的键位序号为13
                // $('button.search123').trigger("click");//触发搜索按钮的点击事件
                active['reload'] ? active['reload'].call(this) : '';
            }
        });
    });


    scrollBar();

    function scrollBar() {
        var height = 0;
        $.get("/3nod_web/report/unQualifiedQualityList/", function (data) {
            height = $(".layui-table").height() * data.count;
        });
        var number = 0;
        var length = 0;
        var time = setInterval(function () {
            number += 1;
            if (number == 12) {
                clearInterval(time);

                active['reload'] ? active['reload'].call(this) : '';
                $('.layui-table-body').scrollTop('0');
            } else {
                length += height / 11;
                $('.layui-table-body').scrollTop(length);  //只有此处有区别
            }
        }, 1000 * 60 * 10);
    }

    setInterval(function () {
        scrollBar()
    }, 13000 * 60 * 10 );


    setInterval(function () {
        location.reload()
    }, 24000 * 60 * 10);
</script>

</body>
</html>